﻿using System;
using System.Collections.Generic;
using System.Text;

namespace SuperX.Helper.OS
{
    public static class IotEnvironment
    {
        private static readonly object _lockObj = new object();

        private static OSCommand _osCommand;

        public static OSCommand OSCommand
        {
            get
            {
                if (_osCommand != null)
                {
                    return _osCommand;
                }

                lock (_lockObj)
                {
                    if (_osCommand != null)
                    {
                        return _osCommand;
                    }

                    return _osCommand = OSCommand.GetNewOSCommand();
                }
            }
        }

        public static WindowsCommand WindowsCommand => OSCommand as WindowsCommand;

        public static LinuxCommand LinuxCommand => OSCommand as LinuxCommand;

        public static bool IsLinux()
        {
            return OSCommand is LinuxCommand;
        }

        public static bool IsWindows()
        {
            return OSCommand is WindowsCommand;
        }
    }
}